IdentifiableEntityManager<TContext, TEntity, TId>

Provides a specialized entity manager for entities that implement IIdentifiable<TId>. Automatically generates GUID identifiers for entities with empty IDs during insertion.

Syntax

public abstract class IdentifiableEntityManager<TContext, TEntity, TId> : EntityManager<TContext, TEntity> where TContext : DbContext where TEntity : class, IIdentifiable<TId> where TId : struct

Inheritance

Constructors

IdentifiableEntityManager

public IdentifiableEntityManager(TContext dataContext, IMessagePublisher messagePublisher)
Create a new instance of the given Manager for a given .

Parameters

  • dataContext TContext: The instance to use for the database connection. Should be injected by the DI container.
  • messagePublisher IMessagePublisher: The SimpleMessageBus instance to use to publish Messages to a Queue. Should be injected by the DI container.

Methods

OnInsertingAsync

public override Task OnInsertingAsync(TEntity entity)
Perform business logic (like setting the entity’s Id) prior to saving the TEntity to the TContext.

Parameters

  • entity TEntity: The TEntity to be inserted.

Returns

Task